package exception;

public class Person {
    private String name;
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws IllagalAgeException {
        if(age<0||age>200){
            //throw new RuntimeException("年龄不符合要求!!!");//非检查异常,一般能够通过代码避免的使用该异常
            throw new IllagalAgeException("年龄不符合要求!!!");
//            throw new Exception("年龄不符合要求!!!");
//            检查异常,非检查异常,区别是检查异常是编程时必须要求被处理的
        }
        this.age = age;
    }
}
